
const _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault');

exports.__esModule = true;
exports.default = void 0;

const _babelHelperVueJsxMergeProps = _interopRequireDefault(require('@vue/babel-helper-vue-jsx-merge-props'));

const _utils = require('../utils');

const _functional = require('../utils/functional');

const _cell = _interopRequireDefault(require('../cell'));

// Utils
// Components
const _createNamespace = (0, _utils.createNamespace)('contact-card');
const createComponent = _createNamespace[0];
const bem = _createNamespace[1];
const t = _createNamespace[2];

function ContactCard(h, props, slots, ctx) {
  const { type } = props;
  const { editable } = props;

  function onClick(event) {
    if (editable) {
      (0, _functional.emit)(ctx, 'click', event);
    }
  }

  function Content() {
    if (type === 'add') {
      return props.addText || t('addText');
    }

    return [h('div', [`${t('name')}\uFF1A${props.name}`]), h('div', [`${t('tel')}\uFF1A${props.tel}`])];
  }

  return h(_cell.default, (0, _babelHelperVueJsxMergeProps.default)([{
    attrs: {
      center: true,
      border: false,
      isLink: editable,
      valueClass: bem('value'),
      icon: type === 'edit' ? 'contact' : 'add-square',
    },
    class: bem([type]),
    on: {
      click: onClick,
    },
  }, (0, _functional.inherit)(ctx)]), [Content()]);
}

ContactCard.props = {
  tel: String,
  name: String,
  addText: String,
  editable: {
    type: Boolean,
    default: true,
  },
  type: {
    type: String,
    default: 'add',
  },
};

const _default = createComponent(ContactCard);

exports.default = _default;
